<%--
  Created by IntelliJ IDEA.
  User: YYY
  Date: 2017/5/14
  Time: 14:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path;
%>
<!DOCTYPE>
<html>
<body class="skin-blue">
<!-- header logo: style can be found in header.less -->

<!-- getHeader -->
<s:action name="getHeader" namespace="/privilege" executeResult="true"/>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <!-- Left side column. contains the logo and sidebar -->

    <!-- getMenus -->
    <s:action name="getMenus" namespace="/privilege" executeResult="true"/>

    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="right-side">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>

                <small id="page-title"></small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li><a href="#">Tables</a></li>
                <li class="active">Data tables</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">

                        <div class="box box-danger">

                            <div class="box-body">
                                <form action="javascript:searchOrder();" class="form-horizontal" name="searchForm">

                                    <div class="form-group">
                                        <input name="userid" id="userid" style="display: none" value="${not empty UserID ? UserID :''}">
                                        <lable style="float: left;margin-left: 30px">订单编号</lable>
                                        <div class="col-sm-2">
                                            <input type="text" id="registerid" class="input-small" style="width: 100%">
                                        </div>

                                        <lable style="float: left">医生姓名</lable>
                                        <div class="col-sm-2">
                                            <input type="text" id="accepterName" class="input-small"
                                                   style="width: 100%">
                                        </div>

                                        <lable style="float: left">就诊人姓名</lable>
                                        <div class="col-sm-2">
                                            <input type="text" id="patientName" class="input-small" style="width: 100%">
                                        </div>

                                        <lable style="float: left">联系电话</lable>
                                        <div class="col-sm-2">
                                            <input type="text" id="userContact" class="input-small" style="width: 100%">
                                        </div>

                                    </div>

                                    <div class="form-group">
                                        <lable style="float: left;margin-left: 30px">订单类型</lable>
                                        <div class="col-sm-2">
                                            <select class="form-control" id="registerguideid" name="registerguideid">
                                                <option value="-1">全部</option>
                                                <option value="1">免费导诊</option>
                                                <option value="2">专家咨询</option>
                                                <option value="3">电话咨询</option>
                                                <option value="4">挂号送药</option>
                                                <option value="5">中医咨询</option>
                                                <option value="6">视频咨询</option>
                                                <option value="7">快速问诊</option>
                                            </select>
                                        </div>
                                        <lable style="float: left">订单状态</lable>
                                        <div class="col-sm-2">
                                            <select class="form-control" id="runstatusid" name="runstatusid">
                                                <option value="1">待支付</option>
                                                <option value="2">待就诊</option>
                                                <option value="3">诊断中</option>
                                                <option value="4">待评价</option>
                                                <option value="5">已完成</option>
                                                <option value="6">已关闭</option>
                                                <option value="-1">全部</option> 
                                            </select>
                                        </div>
                                    </div>

                                    <div class=row
                                         style="display: -webkit-inline-flex; display: inline-flex;align-items: center">
                                        <label style="margin-left: 30px">时间筛选</label>
                                        <div class="input-group form_datetime col-md-2" style="margin-left: 15px;font-weight: normal">
                                            <input type="text" class="form-control date-tm" id="orderCreateTimeStart" name="orderCreateTimeStart"  placeholder="">
                                            <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-time" aria-hidden="true"></span></span>
                                        </div>

                                        <label style="margin-left: 15px;font-weight: normal">至</label>
                                        <div class="input-group form_datetime col-md-2" style="margin-left: 15px;font-weight: normal">
                                            <input type="text" class="form-control date-tm" id="orderCreateTimeEnd" name="orderCreateTimeStart"  placeholder="">
                                            <span class="input-group-addon" id="basic-addon2"><span class="glyphicon glyphicon-time" aria-hidden="true"></span></span>
                                        </div>
                                        <button type="submit" class="btn btn btn-info" style="margin-left: 30px">查询订单
                                        </button>
                                    </div>


                                </form>
                            </div><!-- /.box-body -->
                        </div><!-- /.box -->
                        <form method="post" target="_self" action="" name="listForm">
                            <div class="box-body table-responsive" id="listDiv">

                                <s:property value="res" escape="false"/>
                            </div><!-- /.box-body -->
                        </form>

                    </div><!-- /.box -->


                </div>
            </div>

        </section><!-- /.content -->
    </aside><!-- /.right-side -->
</div><!-- ./wrapper -->
<div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-labelledby="messageModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="messageModalLabel">
                    咨询对话消息
                </h4>
            </div>
            <div class="modal-body" id="modal-body">


            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>

<head>
    <meta charset="UTF-8">
    <title>AdminLTE | Data Tables</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

    <script type="text/javascript" src="<%=basePath%>/js/admin/utils.js"></script>
    <script type="text/javascript" src="<%=basePath%>/js/base/listtable.js"></script>

    <link href="<%=basePath%>/AdminLTE/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
    <script type="text/javascript" src="<%=basePath%>/AdminLTE/js/bootstrap.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="<%=basePath%>/AdminLTE/js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="<%=basePath%>/AdminLTE/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

    <style>
        .table th, .table td {
            text-align: center;
            vertical-align: middle!important;
        }

        .chat-discussion{
            background: #eee;
            padding: 15px;
            height: 400px;
            overflow-y: auto;
        }

        .chat-message
        {
            padding: 10px 20px;
        }

        .message-avatar {
            height: 48px;
            width: 48px;
            border: 1px solid #e7eaec;
            border-radius: 4px;
            margin-top: 1px;
        }

        .chat-discussion .chat-message.left .message-avatar {
            float: left;
            margin-right: 10px;
        }
        .chat-discussion .chat-message.right .message-avatar {
            float: right;
            margin-left: 10px;
        }

        .message {
            background-color: #fff;
            border: 1px solid #e7eaec;
            text-align: left;
            display: block;
            padding: 10px 20px;
            position: relative;
            border-radius: 4px;
        }

        .chat-discussion .chat-message.left .message {
            text-align: left;
            margin-left: 55px;
        }
        .chat-discussion .chat-message.right .message {
            text-align: right;
            margin-right: 55px;
        }

        .message-author
        {
            font-size: 13px;
            color: #337ab7;
            text-decoration: none;
            background-color: transparent;
        }

        .message-date {
            font-size: 10px;
            color: #888888;
        }

        .chat-discussion .chat-message.left .message-date {
            float: right;
        }
        .chat-discussion .chat-message.right .message-date {
            float: left;
        }

        .message-content
        {
            display: block;
            line-height: 1.43;
        }

    </style>

</head>
<script type="text/javascript">

    $('.date-tm').datetimepicker({
        weekStart: 1,
        todayBtn: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1,
        autoclose: true,
        format: 'yyyy-mm-dd hh:ii',
        language: 'zh-CN',
    });

    var type = "${not empty type ? type :''}";

    //查询文章
    function searchOrder() {

        var registerid = Utils.trim(document.forms['searchForm'].elements['registerid'].value);
        var patientName = Utils.trim(document.forms['searchForm'].elements['patientName'].value);
        var accepterName = Utils.trim(document.forms['searchForm'].elements['accepterName'].value);
        var userContact = Utils.trim(document.forms['searchForm'].elements['userContact'].value);

        var orderCreateTimeStart = Utils.trim($("#orderCreateTimeStart").val());
        var orderCreateTimeEnd =Utils.trim($("#orderCreateTimeEnd").val());

        var registerguideid = $("#registerguideid").val();
        var runstatusid = $("#runstatusid").val();

        listTable.filter['registerid'] = registerid;
        listTable.filter['patientName'] = patientName;
        listTable.filter['accepterName'] = accepterName;
        listTable.filter['userContact'] = userContact;
        listTable.filter['registerguideid'] = registerguideid;
        listTable.filter['runstatusid'] = runstatusid;
        listTable.filter['orderCreateTimeStart'] = orderCreateTimeStart;
        listTable.filter['orderCreateTimeEnd'] = orderCreateTimeEnd;
        listTable.filter['currentPage'] = 1;
        listTable.filter['type']=type;
        if ("3"==type)
        {
            listTable.filter['userid'] = Utils.trim($("#userid").val());
        }
        listTable.action = "<%=basePath%>/order/ajaxQueryOrderList.action";

        listTable.loadList();
    }
    
    function queryMessage(ss) {
        var orderid=$(ss).attr("order-id");
        $.ajax({
            type: "POST",
            url: '../order/aiaxQueryOrderImMessage.action?groupid='+orderid,
            cache: false,
            dataType: 'json',
            success: successfun,
            error:errorfun
        });
    }

    function successfun(data) {
        if (data.errorCode >= 0) {
            var content=data.content;
            $("#modal-body").empty();
            $("#modal-body").append(content);
            $("#messageModal").modal();
        }else
        {
            alert(data.errorMsg);
        }
    }

    function errorfun() {
        alert("error");
    }

    $(document).ready(new function () {

        if ("1" == type) {
            $("#page-title").innerHTML="订单管理-进行中订单";
            $("#registerguideid").val("-1");
            $("#runstatusid").val("-1");
            $("#runstatusid option[value='4']").remove();   
            $("#runstatusid option[value='5']").remove();   
            $("#runstatusid option[value='6']").remove();   
             //$("#runstatusid option[value='-1']").remove();   
            //$("#runstatusid").attr("disabled", "disabled");
        }
        else if ("2" == type) {
            $("#page-title").innerHTML="订单管理-已完成订单";
            $("#registerguideid").val("-1");
            $("#runstatusid").val("-1");
            $("#runstatusid option[value='1']").remove();   
            $("#runstatusid option[value='2']").remove();   
            $("#runstatusid option[value='3']").remove(); 
           // $("#runstatusid option[value='-1']").remove();     
             //$("#runstatusid").attr("disabled", "disabled");
        } else if ("3" == type || Utils.isEmpty(type)) {
            $("#page-title").innerHTML="订单管理-全部订单";
            $("#registerguideid").val("-1");
            $("#runstatusid").val("-1");
        } else if ("4" == type) {
            $("#page-title").innerHTML="订单管理-挂号送药";
            $("#registerguideid").val("4");
            $("#registerguideid").attr("disabled", "disabled");
            $("#runstatusid").val("-1");
        }

        searchOrder();
        $('.form_datetime').datetimepicker={
            weekStart: 1,
                todayBtn: 1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                forceParse: 0,
                showMeridian: 1,
                autoclose: true,
                format: 'yyyy-mm-dd hh:ii',
                language: 'zh-CN',
        };
    })
</script>
</html>
